package com.zeng.sim.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 描述信息
 *
 * @author zengwanlin
 * @date 2023-12-19T17:45
 */
@Configuration(proxyBeanMethods = false)
public class SimulatorMvcConfigurer implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
            .addPathPatterns("/**")
            .excludePathPatterns("/simulator/**", "/error", "/", "/login.html", "/sys/login", "/sys/logout",
                    "/admin/css/**", "/admin/images/**", "/admin/js/**", "/component/code/**", "/component/layui/**",
                    "/component/pear/**", "/simulator.config.yml");
    }

}
